/* 
 * File:   msp_control_t.h
 * Author: liujianping
 *
 * Created on 2011年4月30日, 下午12:55
 */

#ifndef MSP_CONTROL_T_H
#define	MSP_CONTROL_T_H

#include "prepare.h"
#include <string>
#include "prepare_service.h"
namespace edm
{
    namespace prepare
    {
        class msp_control_t
        {
        public:
            enum MSP_STAT{UNBLOCKED, EXCEED, BLOCKED};
            
        public:
            msp_control_t(prepare_service_t& prepare_service, const std::string& name, const int concurrency);
            ~msp_control_t();
            
            void increment_concurrency(int c);
            void decrement_concurrency(edm::common::SMTP_HIGH_CODE high, edm::common::SMTP_LOW_CODE low);
            
            MSP_STAT status();
            std::string& msp_name();
            time_t last_block_time();
            time_t last_unblock_time();
            void block(bool blocked);
            bool blocked();
        private:
            prepare_service_t& m_prepare_service;
            std::string m_msp_name;
            int         m_msp_concurrency;
            int         m_courrent_total;
            int         m_continue_blocks;
            bool        m_blocked;
            int         m_delivery_total;
            time_t      m_last_block_time;
            time_t      m_last_unblock_time;
        };
    }
}

#endif	/* MSP_CONTROL_T_H */

